﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="record_detail_o_payment_form.aspx.cs" Inherits="RTGS.Web.form.rtgs.form_rtgs_record_detail_o_payment_form" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="<%= ResolveClientUrl("~/css/validationEngine.jquery.css") %>" rel="stylesheet"
        type="text/css" />
    <script src="<%= ResolveClientUrl("~/script/helper.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveClientUrl("~/script/jquery.validationEngine.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveClientUrl("~/script/autoNumeric-1.7.5.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveClientUrl("~/script/languages/jquery.validationEngine-en.js") %>"
        type="text/javascript"></script>
    <script src="<%= ResolveClientUrl("~/script/jquery.formatCurrency.js") %>" type="text/javascript"></script>
    <script type="text/javascript">

        $(document).ready(function () {

            // $('#<%=txtAmount.ClientID %>').autoNumeric({ aSep: ',', aDec: '.' });

            $('#<%=txtAmount.ClientID %>').blur(function () {
                $('#<%=txtAmount.ClientID %>').formatCurrency();
            });



            $('#<%=txtAccountParticipantsClient.ClientID %>').keydown(function (event) {
                // Allow: backspace, delete, tab, escape, and enter
                if (event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 ||
                // Allow: Ctrl+A
            (event.keyCode == 65 && event.ctrlKey === true) ||
                // Allow: home, end, left, right
            (event.keyCode >= 35 && event.keyCode <= 39)) {
                    // let it happen, don't do anything
                    return;
                }
                else {
                    // Ensure that it is a number and stop the keypress
                    if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105)) {
                        event.preventDefault();
                    }
                }
            });


            $('#<%=txtAccountDebitParticipantsClient.ClientID %>').keydown(function (event) {
                // Allow: backspace, delete, tab, escape, and enter
                if (event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 ||
                // Allow: Ctrl+A
            (event.keyCode == 65 && event.ctrlKey === true) ||
                // Allow: home, end, left, right
            (event.keyCode >= 35 && event.keyCode <= 39)) {
                    // let it happen, don't do anything
                    return;
                }
                else {
                    // Ensure that it is a number and stop the keypress
                    if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105)) {
                        event.preventDefault();
                    }
                }
            });


            $('#<%=txtAmount.ClientID %>').keydown(function (event) {
                // Allow: backspace, delete, tab, escape, and enter
                if (event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 ||
                // Allow: Ctrl+A
            (event.keyCode == 65 && event.ctrlKey === true) ||
                // Allow: home, end, left, right
            (event.keyCode >= 35 && event.keyCode <= 39)) {
                    // let it happen, don't do anything
                    return;
                }
                else {
                    // Ensure that it is a number and stop the keypress
                    if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105)) {
                        event.preventDefault();
                    }
                }
            });

            // binds form submission and fields to the validation engine
            jQuery("#form1").validationEngine();

            //            jQuery("#form1").submit();
            if ($("#form1").validationEngine('validate')) { }
            else jQuery("#form1").submit();

            $("#<%=txtBussinesDay.ClientID %>").datepicker({ showWeek: true, showButtonPanel: true,
                changeMonth: true, changeYear: true, dateFormat: 'dd/mm/yy'//, yearRange: '2010:2030'
            });

            var typeOutgoing = '<%= Request.Params["typeOutgoing"] %>';
            if (typeOutgoing == "all") {
                $("#save").hide();
            }
            else {
                $("#save").show();
            }

            $('#<%=ddlTrn.ClientID %>').change(function () {
                var desc = $("#<%=ddlTrn.ClientID %> option:selected").val();
                $("#<%=txtTrnDesc.ClientID %>").val(desc);


            });

            $("#save").click(function () {
                if ($("#form1").validationEngine('validate')) {
                    var fromMember = encodeURIComponent($("#<%=ddlDebitParticipant.ClientID %> option:selected").val());
                    var toMember = encodeURIComponent($("#<%=ddlCreditParticipant.ClientID %> option:selected").val());

                    if (fromMember != toMember) {
                        var typeOutgoing = '<%= Request.Params["typeOutgoing"] %>';
                        var handlerUrl = '<%= ResolveClientUrl("~/ajaxhandler/rtgs/stp_record_detail_o_payment.ashx") %>';
                        var trn = encodeURIComponent($("#<%=ddlTrn.ClientID %> option:selected").text());
                        var relatedTrn = encodeURIComponent($('#<%=txtRelatedTrn.ClientID %>').val());
                        var debitParticipantsClient = encodeURIComponent($('#<%=txtDebitParticipantsClient.ClientID %>').val());
                        var accountDebitParticipantsClient = encodeURIComponent($('#<%=txtAccountDebitParticipantsClient.ClientID %>').val());
                        var creditParticipantsClient = encodeURIComponent($('#<%=txtCreditParticipantsClient.ClientID %>').val());
                        var accountParticipantsClient = encodeURIComponent($('#<%=txtAccountParticipantsClient.ClientID %>').val());

                        var debitParticipant = encodeURIComponent($('#<%=txtNameDebitParticipant.ClientID %>').val());   //encodeURIComponent($("#<%=ddlDebitParticipant.ClientID %> option:selected").text());
                        var accountDebitParticipant = encodeURIComponent($('#<%=txtAccountDebitParticipant.ClientID %>').val());
                        var memberCodeDebit = encodeURIComponent($("#<%=ddlDebitParticipant.ClientID %> option:selected").val());

                        var creditParticipant = encodeURIComponent($('#<%=txtNameCreditParticipant.ClientID %>').val()); //encodeURIComponent($("#<%=ddlCreditParticipant.ClientID %> option:selected").text());
                        var accountCreditParticipant = encodeURIComponent($('#<%=txtAccountCreditParticipant.ClientID %>').val());
                        var memberCodeCredit = encodeURIComponent($("#<%=ddlCreditParticipant.ClientID %> option:selected").val()); 

                        var amount = encodeURIComponent($('#<%=txtAmount.ClientID %>').val());
                        var currency = encodeURIComponent($('#<%=txtCurrency.ClientID %>').val());

                        var bussinesDay = encodeURIComponent($('#<%=txtBussinesDay.ClientID %>').val());
                        var remitanceInformation = encodeURIComponent($('#<%=txtRemitanceInformation.ClientID %>').val());
                        var detailOfCharges = encodeURIComponent($('#<%=txtDetailOfCharges.ClientID %>').val());
                        var transactionSubTypeCode = encodeURIComponent($('#<%=txtTransactionSubTypeCode.ClientID %>').val());
                        var sender = encodeURIComponent($('#<%=txtSender.ClientID %>').val());
                        var priority = encodeURIComponent($('#<%=txtPriority.ClientID %>').val());
                        var reasoncode = encodeURIComponent($('#<%=txtReason.ClientID %>').val());

                        var ispayment = '<%= Request.Params["ispayment"] %>';
                        var payment = "";
                        if (ispayment == "single") {
                            payment = "103";

                        }

                        if (ispayment == "general") {
                            payment = "202";
                        }



                        var id = $('#<%= hfID.ClientID %>').val();

                        var param = '&trn=' + trn
                             + '&relatedTrn=' + relatedTrn
                             + '&debitParticipantsClient=' + debitParticipantsClient
                             + '&accountDebitParticipantsClient=' + accountDebitParticipantsClient
                             + '&creditParticipantsClient=' + creditParticipantsClient
                             + '&accountParticipantsClient=' + accountParticipantsClient
                             + '&debitParticipant=' + debitParticipant
                             + '&accountDebitParticipant=' + accountDebitParticipant
                             + '&memberCodeDebit=' + memberCodeDebit
                             + '&creditParticipant=' + creditParticipant
                             + '&accountCreditParticipant=' + accountCreditParticipant
                             + '&memberCodeCredit=' + memberCodeCredit
                             + '&amount=' + amount
                             + '&currency=' + currency
                             + '&bussinesDay=' + bussinesDay
                             + '&remitanceInformation=' + remitanceInformation
                             + '&detailOfCharges=' + detailOfCharges
                             + '&transactionSubTypeCode=' + transactionSubTypeCode
                             + '&sender=' + sender
                             + '&priority=' + priority
                             + '&reasoncode=' + reasoncode
                             + '&payment=' + payment
                               ;

                        if (id == 0)
                            CallAjax(handlerUrl, "?method=insert&typeOutgoing=" + typeOutgoing + param);
                        else
                            CallAjax(handlerUrl, "?method=update&typeOutgoing=" + typeOutgoing + param + "&id=" + id);

                        parent.$('#dialog').dialog("close");

                        setTimeout("parent.$('#table').trigger('reloadGrid');", 3000);
                    }
                    else {
                        alert("Data from member dan to member tidak boleh sama ..");
                    }
                    return false;
                }
            });

        });

        $('#<%=ddlDebitParticipant.ClientID %>').change(function () {
            var membercode = $("#<%=ddlDebitParticipant.ClientID %> option:selected").val();
            var handlerUrl = '<%= ResolveClientUrl("~/ajaxhandler/rtgs/stp_record_detail_o_payment.ashx") %>';
            if (membercode != "") {
                $.ajax({
                    type: 'POST',
                    url: handlerUrl + "?method=getaccountmemberbycode&membercode=" + membercode,
                    contentType: 'application/json',
                    dataType: 'json',
                    success: function (datas) {
                        $('#<%=txtAccountDebitParticipant.ClientID %>').val(datas);
                       

                        $.ajax({
                            type: 'POST',
                            url: handlerUrl + "?method=getnamememberbycode&membercode=" + membercode,
                            contentType: 'application/json',
                            dataType: 'json',
                            success: function (datas) {
                                $('#<%=txtNameDebitParticipant.ClientID %>').val(datas);
                               
                            },
                            error: function () {
                                alert('Error!');
                            }
                        });

                    },
                    error: function () {
                        alert('Error!');
                    }
                });
            }

        });

        $('#<%=ddlCreditParticipant.ClientID %>').change(function () {
            var membercode = $("#<%=ddlCreditParticipant.ClientID %> option:selected").val();
            var handlerUrl = '<%= ResolveClientUrl("~/ajaxhandler/rtgs/stp_record_detail_o_payment.ashx") %>';
            if (membercode != "") {

                $.ajax({
                    type: 'POST',
                    url: handlerUrl + "?method=getaccountmemberbycode&membercode=" + membercode,
                    contentType: 'application/json',
                    dataType: 'json',
                    success: function (datas) {
                        $('#<%=txtAccountCreditParticipant.ClientID %>').val(datas);

                        $.ajax({
                            type: 'POST',
                            url: handlerUrl + "?method=getnamememberbycode&membercode=" + membercode,
                            contentType: 'application/json',
                            dataType: 'json',
                            success: function (datas) {
                                $('#<%=txtNameCreditParticipant.ClientID %>').val(datas);

                            },
                            error: function () {
                                alert('Error!');
                            }
                        });


                    },
                    error: function () {
                        alert('Error!');
                    }
                });
            }

        });

      

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Panel ID="pnlGroupBox" runat="server" GroupingText="TRN">
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td>
                        TRN
                    </td>
                    <td style="padding-left: 120px">
                        <asp:DropDownList ID="ddlTrn" runat="server" CssClass="validate[required]" Width="250px">
                        </asp:DropDownList>
                    </td>
                    <td style="padding-left: 40px">
                        Related TRN
                    </td>
                    <td style="padding-left: 20px">
                        <asp:TextBox ID="txtRelatedTrn" CssClass="validate[required]" runat="server" ReadOnly="true"
                            Width="200px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        Trn Desc.
                    </td>
                    <td style="padding-left: 120px">
                        <asp:TextBox ID="txtTrnDesc" ReadOnly="true" runat="server" Width="500" Rows="1"></asp:TextBox>
                    </td>
                </tr>
            </table>
        </asp:Panel>
        <table border="0">
            <tr>
                <td>
                    <asp:Panel ID="Panel1" runat="server" GroupingText="Debit Participant's Client">
                        <table border="0">
                            <tr>
                                <td>
                                    Debit Participant's Client
                                </td>
                                <td>
                                    <asp:TextBox Enabled="false" ID="txtDebitParticipantsClient" MaxLength="140"
                                        ReadOnly="true" runat="server" TextMode="MultiLine" Width="300px" Rows="1"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Account of Debit Participant's Client
                                </td>
                                <td>
                                    <asp:TextBox Enabled="false" ID="txtAccountDebitParticipantsClient"
                                        MaxLength="24" ReadOnly="true" runat="server" Width="300px"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
                <td>
                    <asp:Panel ID="Panel2" runat="server" GroupingText="Credit Participant's Client">
                        <table border="0">
                            <tr>
                                <td>
                                    Credit Participant's Client
                                </td>
                                <td>
                                    <asp:TextBox Enabled="false"  ID="txtCreditParticipantsClient" runat="server"
                                        MaxLength="140" ReadOnly="true" TextMode="MultiLine" Width="300px" Rows="1"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Account of Debit Participant's Client
                                </td>
                                <td>
                                    <asp:TextBox Enabled="false"  ID="txtAccountParticipantsClient" MaxLength="24"
                                        runat="server" ReadOnly="true" Width="300px"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Panel ID="Panel3" runat="server" GroupingText="Debit Participant">
                        <table border="0">
                            <tr>
                                <td>
                                    Debit Participant
                                </td>
                                <td>
                                    <asp:DropDownList  ID="ddlDebitParticipant" runat="server"
                                        Enabled="false" Width="300px">
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Account
                                </td>
                                <td>
                                   

                                         <asp:TextBox ID="txtAccountDebitParticipant" MaxLength="24" runat="server" Enabled="false"
                                        Width="300px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Name
                                </td>
                                <td>
                                    <asp:TextBox ID="txtNameDebitParticipant" MaxLength="140" runat="server" Enabled="false"
                                        Width="300px"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
                <td>
                    <asp:Panel ID="Panel4" runat="server" GroupingText="Credit Participant">
                        <table border="0">
                            <tr>
                                <td>
                                    Credit Participant
                                </td>
                                <td>
                                    <asp:DropDownList  ID="ddlCreditParticipant" runat="server"
                                        Enabled="false" Width="300px">
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Account
                                </td>
                                <td>
                                   

                                         <asp:TextBox ID="txtAccountCreditParticipant" MaxLength="24" runat="server" Enabled="false"
                                        Width="300px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Name
                                </td>
                                <td>
                                    <asp:TextBox ID="txtNameCreditParticipant" MaxLength="140" runat="server" Enabled="false"   
                                        Width="300px"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Panel ID="Panel5" runat="server" GroupingText="Amount">
                        <table border="0">
                            <tr>
                                <td>
                                    Amount
                                </td>
                                <td>
                                    <asp:TextBox CssClass="validate[required]"  ID="txtAmount" runat="server" Width="300px"
                                        ReadOnly="true" Rows="1"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Currency
                                </td>
                                <td>
                                    <asp:TextBox ID="txtCurrency" MaxLength="3" Text="IDR" runat="server" ReadOnly="true" Width="300px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Bussines Day
                                </td>
                                <td>
                                    <asp:TextBox ID="txtBussinesDay" CssClass="validate[required]" MaxLength="8" runat="server"
                                        ReadOnly="true" Width="300px"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
                <td>
                    <asp:Panel ID="Panel6" runat="server" GroupingText="Details">
                        <table border="0">
                            <tr>
                                <td>
                                    Remitance Information
                                </td>
                                <td>
                                    <asp:TextBox ID="txtRemitanceInformation" MaxLength="72" ReadOnly="true" TextMode="MultiLine"
                                        runat="server" Width="300px" Rows="1"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Details Of Charges
                                </td>
                                <td>
                                    <asp:TextBox ID="txtDetailOfCharges" MaxLength="1" ReadOnly="true" runat="server"
                                        Width="300px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Transaction's Sub Type Code
                                </td>
                                <td>
                                    <asp:TextBox ID="txtTransactionSubTypeCode" MaxLength="3" ReadOnly="true" runat="server"
                                        Width="300px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Sender To Receiver Information
                                </td>
                                <td>
                                    <asp:TextBox ID="txtSender" MaxLength="96" ReadOnly="true" runat="server" Width="300px"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Panel ID="Panel7" runat="server" GroupingText="Priority">
                        <table border="0">
                            <tr>
                                <td>
                                    Priority
                                </td>
                                <td>
                                    <asp:TextBox ID="txtPriority" runat="server" ReadOnly="false" MaxLength="2" Width="300px"
                                        Rows="1"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Reason
                                </td>
                                <td>
                                    <asp:TextBox ID="txtReason" runat="server" Width="300px" ReadOnly="true" Rows="1"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
                <td>
                    <asp:Panel ID="Panel8" runat="server" GroupingText="Draft Details">
                        <table border="0">
                            <tr>
                                <td>
                                    Document Step
                                </td>
                                <td>
                                    <asp:TextBox ID="txtDocumentStep" ReadOnly="true" runat="server" Width="300px" Rows="1"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Comment Charges
                                </td>
                                <td>
                                    <asp:TextBox ID="txtCommentCharges" ReadOnly="true" runat="server" Width="300px"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <div style="text-align: right; padding-top: 10px;">
                    <%-- <a href="#" id="print" runat="server" class="dialog_link ui-state-default ui-corner-all" alt="Print"
                            ><span class="ui-icon ui-icon-close">
                            </span>Print</a>&nbsp;--%>
                        <a href="#" id="save" class="dialog_link ui-state-default ui-corner-all" alt="Save"
                            onclick="parent.$('#dialog').dialog('Save');"><span class="ui-icon ui-icon-close">
                            </span>Save</a>&nbsp;<a href="#" id="close" class="dialog_link ui-state-default ui-corner-all"
                                alt="Close" onclick="parent.$('#dialog').dialog('close');"><span class="ui-icon ui-icon-close">
                                </span>Close</a>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:HiddenField ID="hfID" runat="server" />
                </td>
            </tr>
        </table>
    </div>

   
    </form>
</body>
</html>
